package com.vercal.demoverticalviewpager.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.vercal.demoverticalviewpager.R;
import com.vercal.demoverticalviewpager.bean.modelData;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public class ContentFragment extends Fragment {

    private TextView tv_content;
    private TextView tv_room1;
    private TextView tv_room2;
    private TextView tv_room3;
    private TextView tv_value1;
    private TextView tv_value2;
    private TextView tv_value3;

    private modelData data;

    private int position;

    public ContentFragment() {
    }

//    public static Fragment newInstance(modelData content, int position) {
//        Bundle args = new Bundle();
//        args.putSerializable("modelData", content);
//        args.putInt("position", position);
//        ContentFragment fragment = new ContentFragment();
//        fragment.setArguments(args);
//        return fragment;
//    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.home_banner_layout, container, false);
        initView(view);
        if(null!=data&&null!=data.getModel_name()){
            tv_content.setText(data.getModel_name());
            tv_room1.setText(data.getRoom_name1());
            tv_room2.setText(data.getRoom_name2());
            tv_room3.setText(data.getRoom_name3());
            tv_value1.setText(data.getValue1());
            tv_value2.setText(data.getValue2());
            tv_value3.setText(data.getValue3());
        }
        return view;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle args = getArguments();
        if (null != args && null != args.getSerializable("modelData")) {
            data= (modelData) args.getSerializable("modelData");
            position=args.getInt("position");


        }
    }

    private void initView(View view) {
        tv_content=view.findViewById(R.id.tv_num);
        tv_room1=view.findViewById(R.id.tv_room1);
        tv_room2=view.findViewById(R.id.tv_room2);
        tv_room3=view.findViewById(R.id.tv_room3);
        tv_value1=view.findViewById(R.id.tv_value1);
        tv_value2=view.findViewById(R.id.tv_value2);
        tv_value3=view.findViewById(R.id.tv_value3);

    }



}
